package com.izocen.rules.assembler.operator.chain.unit;

import com.izocen.rules.assembler.operator.chain.AbstractOperator;
import com.izocen.rules.common.conts.ScriptOpetorConts;

/**
 * 包含表达是
 * 
 */
public class ContainsOperator  extends AbstractOperator{

	public ContainsOperator(String type) {
		super(type);
	}

	/* alarmId contains "33"
	 * 
	 * " 's2s1'.indexOf('ss') != -1";
	 * 包含属于字符串
	 */
	@Override
	protected String format(String message) throws Exception {
		message = this.templateSimpleParam(message);
		String[] arr = message.split(this.operatorType);
		String left  = arr[0].trim();
		String right = arr[1].trim();
		StringBuffer sb = new StringBuffer();
		sb.append(left);
		sb.append(ScriptOpetorConts.SCRIPT_INDEX_OF).append(ScriptOpetorConts.SCRIPT_LEFT_BRACKETS);
		sb.append(right);
		sb.append(ScriptOpetorConts.SCRIPT_RIGHT_BRACKETS);
		sb.append(ScriptOpetorConts.SCRIPT_BLANK).append(ScriptOpetorConts.SCRIPT_CONTAINS);
		return sb.toString();
	}

}
